<?php
include("../include/function.php");
dbconnect();
session_start();
?>
<script src="http://localhost/php/login/js/jquery.js"></script>
<script>
$(document).ready(function(){
alert
$(".projectname").keyup(function(){
var proj = $(".projectname").val();
$.ajax({url:"autoproject.php?value=" +proj,

success:function(result)
{
$(".option").show();
$(".option").html(result);
$(".option").each(function()
{
 $(".option ul li").click(function()
 {
 var optionname = $(this).html();
 $(".projectname").val(optionname);
 });
});


},

error:function(result)
{
$(".option").html(result);
}
});
});


});

</script>
<script>
$(document).ready(function(){
alert
$(".empname").keyup(function(){
var proj = $(".empname").val();
$.ajax({url:"autoemp.php?value=" +proj,

success:function(result)
{
$(".optionemp").show();
$(".optionemp").html(result);
$(".optionemp").each(function()
{
 $(".optionemp ul li").click(function()
 {
 var optionname = $(this).html();
 $(".empname").val(optionname);
 });
});


},

error:function(result)
{
$(".optionemp").html(result);
}
});
});


});

</script>




<?php
if($_SESSION["loggedin"]==true && $_SESSION["role"]==admin)
{
if(isset($_SESSION[msg]))
{
echo $_SESSION[msg];
unset($_SESSION[msg]);
}
$id =$_GET['id'];
$sel ="SELECT * from allocation WHERE alloid='$id'";
$s  = mysql_query($sel);
$sq = mysql_fetch_array($s);
?>
<form action="edit.php" method="post">
<label>Project Name</label>
<input type="hidden" name="allid" value="<?php echo $sq[alloid]; ?>"/>
<input type="text" name="projectname" class="projectname" value="<?php echo $sq[projectname]; ?>"/>
<div class="option" style="display:none;width:120px;height:40px;overflow-x:auto;overflow-y:scroll;position:relative;"></div>
<label>Employee Name</label>
<input type="text" name="empname" class="empname" value="<?php echo $sq[empname]; ?>"/>
<div class="optionemp" style="display:none;width:120px;height:40px;overflow-x:auto;overflow-y:scroll;position:relative;"></div>

<input type="submit" value="save" name="check1"/>
</form>
<?php
if(isset($_POST['check1']))
{
$id =$_POST['allid'];
$projectname = $_POST['projectname'];
$empname = $_POST['empname'];

$updatevalue =array();

$updatevalue[projectname] = $projectname;
$updatevalue[empname] = $empname;

$update = updatequery("allocation",$updatevalue,"alloid",$id);

/* $updatea = "UPDATE allocation SET projectname='$projectname',empname='$empname' WHERE alloid='$id'";
//print_r($updatea);
$updateall = mysql_query($updatea); */
header("Location: list.php");
}


}
else
{
header("Location: login.php");
}
?>